#ifndef CHOOSEFRIENDDIALOG_H
#define CHOOSEFRIENDDIALOG_H

#include <QDialog>
#include <QWidget>

class QHBoxLayout;
class QCheckBox;
class QLabel;
class QScrollArea;
class ChooseFriendDialog;

/////////// 选择好友元素窗口
class ChooseFriendDialog : public QDialog
{
    Q_OBJECT
public:
    ChooseFriendDialog(QWidget* parent, const QString& userId);

    void addFriendItem(const QString& userId, const QIcon& avatar, const QString& name, bool checked);
    void addSelectedFriendItem(const QString& userId, const QIcon& avatar, const QString& name);
    void removeSelectedFriendItem(const QString& userId);

private:
    void initLeftList(QHBoxLayout* layout);
    void initRightList(QHBoxLayout* layout);

    void initData();

    void onClickedByFinishBtn();

private:
    QList<QString> generateMemberList();

private:
    QWidget* totalContainer;    // 左侧全部的好友列表
    QWidget* selectedContainer; // 右侧已选择的好友列表

    QString userId;
};


/////////// 具体每一条选择所对应的好友控件
class ChooseFriendItem : public QWidget
{
    Q_OBJECT
public:
    ChooseFriendItem(ChooseFriendDialog* owner, const QString& userId, const QIcon& avatar, const QString& name, bool checked);
    QString getUserId();
    QCheckBox* getCheckBox();
protected:
    void paintEvent(QPaintEvent* event);
    void enterEvent(QEnterEvent* event);
    void leaveEvent(QEvent* event);

private:
    bool isHover;
    QCheckBox* checkBox;
    QPushButton* avatarBtn;
    QLabel* nameLabel;

    QString userId;
};

#endif // CHOOSEFRIENDDIALOG_H
